package com.mstore.interceptor;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.mstore.config.Constants;

public class ContextInitListener implements ServletContextListener {

	@Override
	public void contextDestroyed(ServletContextEvent contextEvent) {
	}

	@Override
	public void contextInitialized(ServletContextEvent contextEvent) {
		Properties props = new Properties();
		InputStream inputStream = null;

		try {
			inputStream = getClass().getResourceAsStream(
					"/properties/ServiceURL.properties");
			props.load(inputStream);
			Constants.createMenuUrl = (String) props.get("createMenuUrl");
			Constants.weixinCallbackUrl = (String) props
					.get("weixinCallbackUrl");
			Constants.memberUrl = (String) props.get("memberUrl");
			Constants.emailCallback = (String) props.get("emailCallback");
			Constants.alipayGateway = (String) props.get("alipayGateway");
			Constants.alipayAccount = (String) props.get("alipayAccount");
		}
		catch (IOException e) {
			e.printStackTrace();
		}

	}

}
